package LeetCode.month02.day54;

import java.util.*;

public class Test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        Deque<int[]> win = new ArrayDeque<>();
        Deque<int[]> lose = new ArrayDeque<>();
        String[] strings = s.split(" ");
        for (int i = 0; i < strings.length; i++) {
            win.add(new int[]{Integer.parseInt(strings[i]),i});
        }
        while(win.size()>=6){        //5 3 4 2
            int n = win.size();
            while(n>0){
                if(n!=1) {
                    int[] a = win.removeFirst();
                    int[] b = win.removeFirst();
                    if (a[0] >= b[0]){
                        win.add(a);
                    }
                    else {
                        win.add(b);
                    }
                    n -= 2;
                }else{
                    win.add(win.removeFirst());
                }
            }
        }
        if(win.size()==3){
            int[] a = win.removeFirst();
            int[] b = win.removeFirst();
            int[] c = win.removeFirst();
            if(a[0]>=b[0]) System.out.println(a[1]+" "+b[1]+" "+c[1]);
            else System.out.println(b[1]+" "+a[1]+" "+c[1]);
        }else if(win.size()==4){
            int[] a = win.removeFirst();
            int[] b = win.removeFirst();
            int[] c = win.removeFirst();
            int[] d = win.removeFirst();
            swap(a,b);
            swap(c,d);
            swap(a,c);
            swap(b,d);
            System.out.println(a[1]+" "+c[1]+" "+b[1]);
        }else{
            int[] a = win.removeFirst();
            int[] b = win.removeFirst();
            int[] c = win.removeFirst();
            int[] d = win.removeFirst();
            int[] e = win.removeFirst();
            swap(a,b);
            swap(c,d);
            swap(a,c);
            System.out.println(a[1]+" "+c[1]+" "+e[1]);
        }
    }

    private static void swap(int[] a, int[] b) {
        if(a[0]<b[0]){
            int temp = a[0];
            a[0] = b[0];
            b[0] = temp;

            temp = a[1];
            a[1] = b[1];
            b[1] = temp;
        }
    }
}
